import { resolve } from 'path'
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig({
  main: {
    plugins: [externalizeDepsPlugin()]
  },
  preload: {
    plugins: [externalizeDepsPlugin()]
  },
  renderer: {
    resolve: {
      alias: {
        '@renderer': resolve('src/renderer/src')
      }
    },
    plugins: [vue()],
    css: {
      preprocessorOptions: {
        scss: {
          additionalData: `@import "@renderer/assets/scss/global.scss";@import "@renderer/assets/scss/main.scss";`
        },
      }
    },
    server: {
      proxy: {
        '/api': {
          target: 'http://test-pucs.riding-evolved.com', // 目标服务器地址
          changeOrigin: true, // 是否改变源
          rewrite: (path) => path.replace(/^\/api/, ''), // 重写路径：去掉路径中的/api
        }
      }
    }
  }
})
